<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>view/workArea/tools/returnToolsFillinfo</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/global.css">
		<link rel="stylesheet" href="../../../css/style.css">
		<link rel="stylesheet" href="../../../css/mui.picker.css">
		<link rel="stylesheet" href="../../../css/mui.poppicker.css">
		<style>
			input[type=text] {
			    padding: 10px 0 !important;
			}
			input[type=number] {
			    padding: 10px 0 !important;
			}
			.sel{
				font-size: 12px;
				margin-left: 10px;
				color: #ffffff;
				background: #ea1e1a;
				height: 20px;
				line-height: 12px !important;
				margin-top: 16px;
				border-radius: 5px;
				padding: 5px;
			}
			.mui-btn-select{
				line-height: 3.125rem;
				color: #a9a9a9;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">工具归还</h1>
		</header>
		<div class="mui-content">
			<div class="details_con" id="form_info">
				<div class="clum">
					<span class="name">快递单号<em class="t_red">*</em></span>
					<input type="text" class="d_ipt" id="reexpressnumber" name="reexpressnumber" required="required" placeholder="请输入快递单号" />
				</div>
				<div class="clum">
					<span class="name">快递公司<em class="t_red">*</em></span>
					<!-- <input type="text" class="d_ipt" id="reexpresscompany" name="reexpresscompany" required="required" placeholder="请输入快递公司" /> -->
					<input type="hidden" id="reexpresscompany" name="reexpresscompany" required="required" placeholder="请选择快递公司" />
					<span class="txt">
						<button id='reexpresscompanySel' class="mui-btn-select" type='button'>请选择快递公司</button>
					</span>
				</div>
				<div class="clum autoHeight">
					<span class="name">收货地址</span>
					<div class="clear"></div>
					<!-- <textarea class="textarea">上海浦东新区金海路1000号7号楼303室  朱立静/15221622568/13916216911(lijing.zhu@thermofisher.com)</textarea> -->
					<textarea class="textarea">上海浦东新区远航路958号2号库   收件人：王君 赛默飞还库备件   联系电话：18001959110</textarea>
				</div>
			</div>
			<div class="btn_box">
				<span class="fl" id="cancelBtn">返回</span>
				<span class="fr red" id="submitBtn">提交</span>
			</div>
			<div style="height: 50px;"></div>
		</div>

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<script src="../../../js/mui.picker.js"></script>
		<script src="../../../js/mui.poppicker.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">
			(function($, doc) {
				$.init();

				$.plusReady(function() {
					// 从上一个页面取值
					var self = plus.webview.currentWebview();
					var tools = self.tools;
					
					// 提交
					h('#submitBtn').tap(function() {
						// 提交校验
						if (h("#reexpressnumber").val() == "") {
							app.toast("请输入快递单号");
							return false;
						} else {
							var dh = h("#reexpressnumber").val();
							// 单号内容校验
							if(!/^[a-zA-Z\d]{8,35}$/.test(dh)){
								app.toast("快递单号内容格式错误");  
								return false; 
							}
						}
						if (h("#reexpresscompany").val() == "") {
							app.toast("请选择快递公司");
							return false;
						}
						var formObj = {
							"reexpressnumber" : h("#reexpressnumber").val(),
							"reexpresscompany" : h("#reexpresscompany").val(),
							"enginner_id" : app.getUser().enginnerId
						};
						// POST参数对象
						var postParam = {
							"applyMain" : JSON.stringify(formObj),
							"applyTools" :  tools
						}
						app.showWaiting('加载中...')
						// 提交数据
						ajaxPost(BASE_URL + "cc/tool/toolReturnLib", postParam, function(data) {
							app.closeWaiting()
							// console.log(JSON.stringify(data));
							if (data.code == 200) {
								var dataObj = JSON.parse(data.data);
								var status = dataObj.status;
								if (status == "1") {
									// cc接口返回成功
									app.toast("还库成功");
								} else {
									// cc接口返回失败
									app.toast(dataObj.message);
								}
								// 返回上一页并刷新
								var priorPage = plus.webview.getWebviewById('view/workArea/tools/returnTools');
								priorPage.evalJS('selectList()')
								$.back()
							} else {
								//还货失败
								app.toast(data.msg);
							}
						}, function(errorMsg) {
							app.closeWaiting()
							console.log(JSON.stringify(errorMsg))
						});
					});
					
					// 返回
					h('#cancelBtn').tap(function() {
						$.back();
					});
					
					// 物流公司下拉
					h('#reexpresscompanySel').tap(function() {
						document.activeElement.blur();
						app.hideSoftKeybord();
						var userPicker = new $.PopPicker();
						ajaxGetJson(BASE_URL + 'cc/dict/selectCCDict', {
							tableName: 'ExpressCompany',
							engineerId: app.getUser().enginnerId
						}, function(data) {
							// console.log(JSON.stringify(data))
							if (!data) {
								app.toast("无快递公司数据")
								return
							}
							userPicker.setData(data);
							userPicker.show(function(items) {
								h('#reexpresscompanySel').html(items[0].text)
								h('#reexpresscompany').val(items[0].value)
								userPicker.dispose()
							});
						});
					});
				});
			}(mui, document));
		</script>
		<!-- js代码 end -->

	</body>

</html>
